﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using GameSchoolApplication.Models;
using System.Web.Security;

namespace GameSchoolApplication.Helper
{
	public class Helper
	{

	}

	public class MemberShip
	{
		private static GameSchoolWebContext _db = new GameSchoolWebContext();

		public static bool ValiDateUser(string userName, string passWord)
		{
			var item =	_db.Persons
						.Where(m => m.UserName == userName && m.Password == passWord)
					    .SingleOrDefault();
			if (item != null)
			{
				return true;
			}
			return false;
		}

		public static bool IsGroup(Person person, string groupName)
		{
			var item = _db.Persons.Where(m => m.UserName == person.UserName)
									.SingleOrDefault();

			if (item.Group == groupName)
			{
				return true;
			}
			return false;
		}

		public static bool 	BelongsTo(string name)
		{
			var item = _db.Persons.Where(m => m.UserName == name).SingleOrDefault();

			if(item.Group == "Teacher")
			{
				return true;
			}
			return false;
		}
	}
}